package rad.framework.uml2.classdiagram.part;

import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import rad.framework.uml2.classdiagram.providers.UMLElementTypes;
import rad.framework.uml2.uml.edit.UMLEditPlugin;

import org.eclipse.gef.Tool;
import org.eclipse.gef.palette.PaletteContainer;
import org.eclipse.gef.palette.PaletteDrawer;
import org.eclipse.gef.palette.PaletteRoot;
import org.eclipse.gef.palette.ToolEntry;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeConnectionTool;
import org.eclipse.gmf.runtime.diagram.ui.tools.UnspecifiedTypeCreationTool;
import org.eclipse.jface.resource.ImageDescriptor;

/**
 * @generated
 */
public class UMLPaletteFactory {

	/**
	 * @generated
	 */
	public void fillPalette(PaletteRoot paletteRoot) {
		paletteRoot.add(createEntityBeanDiagram1Group());
		paletteRoot.add(createSessionBeanDiagram2Group());
		paletteRoot.add(createUseCaseDiagram3Group());
	}

	/**
	 * @generated
	 */
	private PaletteContainer createEntityBeanDiagram1Group() {
		PaletteContainer paletteContainer = new PaletteDrawer(
				"Entity Bean Diagram");
		paletteContainer.setDescription("Tools for defining entity beans");
		paletteContainer.add(createEntity1CreationTool());
		paletteContainer.add(createProperty2CreationTool());
		paletteContainer.add(createEnumeration3CreationTool());
		paletteContainer.add(createLiteral4CreationTool());
		paletteContainer.add(createGeneralization5CreationTool());
		paletteContainer.add(createOnetoMany6CreationTool());
		paletteContainer.add(createManytoOne7CreationTool());
		paletteContainer.add(createManytoMany8CreationTool());
		paletteContainer.add(createOnetoOne9CreationTool());
		return paletteContainer;
	}

	/**
	 * @generated
	 */
	private PaletteContainer createSessionBeanDiagram2Group() {
		PaletteContainer paletteContainer = new PaletteDrawer(
				"Session Bean Diagram");
		paletteContainer
				.setDescription("Tools for defining stateless session beans");
		paletteContainer.add(createInterface1CreationTool());
		paletteContainer.add(createOperation2CreationTool());
		paletteContainer.add(createDependency3CreationTool());
		return paletteContainer;
	}

	/**
	 * @generated
	 */
	private PaletteContainer createUseCaseDiagram3Group() {
		PaletteContainer paletteContainer = new PaletteDrawer(
				"Use Case Diagram");
		paletteContainer.setDescription("Tools for defining use cases");
		paletteContainer.add(createActor1CreationTool());
		paletteContainer.add(createUseCase2CreationTool());
		paletteContainer.add(createAssociation3CreationTool());
		return paletteContainer;
	}

	/**
	 * @generated
	 */
	private ToolEntry createEntity1CreationTool() {
		ImageDescriptor smallImage;
		ImageDescriptor largeImage;

		smallImage = UMLElementTypes
				.getImageDescriptor(UMLElementTypes.Class_1001);

		largeImage = smallImage;

		final List elementTypes = new ArrayList();
		elementTypes.add(UMLElementTypes.Class_1001);
		ToolEntry result = new NodeToolEntry("Entity",
				"Create a new Entity Bean", smallImage, largeImage,
				elementTypes);

		return result;
	}

	/**
	 * @generated
	 */
	private ToolEntry createProperty2CreationTool() {
		ImageDescriptor smallImage;
		ImageDescriptor largeImage;

		smallImage = UMLElementTypes
				.getImageDescriptor(UMLElementTypes.Property_2001);

		largeImage = smallImage;

		final List elementTypes = new ArrayList();
		elementTypes.add(UMLElementTypes.Property_2001);
		ToolEntry result = new NodeToolEntry("Property",
				"Create a new Property", smallImage, largeImage, elementTypes);

		return result;
	}

	/**
	 * @generated
	 */
	private ToolEntry createEnumeration3CreationTool() {
		ImageDescriptor smallImage;
		ImageDescriptor largeImage;

		smallImage = UMLElementTypes
				.getImageDescriptor(UMLElementTypes.Enumeration_1002);

		largeImage = smallImage;

		final List elementTypes = new ArrayList();
		elementTypes.add(UMLElementTypes.Enumeration_1002);
		ToolEntry result = new NodeToolEntry("Enumeration",
				"Create a new Enumeration", smallImage, largeImage,
				elementTypes);

		return result;
	}

	/**
	 * @generated
	 */
	private ToolEntry createLiteral4CreationTool() {
		ImageDescriptor smallImage;
		ImageDescriptor largeImage;

		smallImage = UMLElementTypes
				.getImageDescriptor(UMLElementTypes.EnumerationLiteral_2002);

		largeImage = smallImage;

		final List elementTypes = new ArrayList();
		elementTypes.add(UMLElementTypes.EnumerationLiteral_2002);
		ToolEntry result = new NodeToolEntry("Literal", "Create a new Literal",
				smallImage, largeImage, elementTypes);

		return result;
	}

	/**
	 * @generated
	 */
	private ToolEntry createGeneralization5CreationTool() {
		ImageDescriptor smallImage;
		ImageDescriptor largeImage;

		smallImage = UMLElementTypes
				.getImageDescriptor(UMLElementTypes.Generalization_3001);

		largeImage = smallImage;

		final List relationshipTypes = new ArrayList();
		relationshipTypes.add(UMLElementTypes.Generalization_3001);
		ToolEntry result = new LinkToolEntry("Generalization",
				"Create a new Generalization", smallImage, largeImage,
				relationshipTypes);

		return result;
	}

	/**
	 * @generated NOT
	 */
	private ToolEntry createOnetoMany6CreationTool() {
		ImageDescriptor smallImage;
		ImageDescriptor largeImage;

		// smallImage = UMLElementTypes
		// .getImageDescriptor(UMLElementTypes.Association_3002);

		smallImage = ImageDescriptor.createFromURL((URL) UMLEditPlugin.INSTANCE
				.getImage("full/obj16/Association_composite"));

		largeImage = smallImage;

		final List relationshipTypes = new ArrayList();
		relationshipTypes.add(UMLElementTypes.Association_3002);
		ToolEntry result = new LinkToolEntry("One to Many",
				"Create a new One to Many Composition Association", smallImage,
				largeImage, relationshipTypes);

		return result;
	}

	/**
	 * @generated NOT
	 */
	private ToolEntry createManytoOne7CreationTool() {
		ImageDescriptor smallImage;
		ImageDescriptor largeImage;

		//		smallImage = UMLElementTypes
		//				.getImageDescriptor(UMLElementTypes.Association_3003);
		smallImage = ImageDescriptor.createFromURL((URL) UMLEditPlugin.INSTANCE
				.getImage("full/obj16/ControlFlow"));

		largeImage = smallImage;

		final List relationshipTypes = new ArrayList();
		relationshipTypes.add(UMLElementTypes.Association_3003);
		ToolEntry result = new LinkToolEntry("Many to One",
				"Create a new Many to One Navigable Association", smallImage,
				largeImage, relationshipTypes);

		return result;
	}

	/**
	 * @generated
	 */
	private ToolEntry createManytoMany8CreationTool() {
		ImageDescriptor smallImage;
		ImageDescriptor largeImage;

		smallImage = UMLElementTypes
				.getImageDescriptor(UMLElementTypes.Association_3004);

		largeImage = smallImage;

		final List relationshipTypes = new ArrayList();
		relationshipTypes.add(UMLElementTypes.Association_3004);
		ToolEntry result = new LinkToolEntry("Many to Many",
				"Create a new Many to Many Association", smallImage,
				largeImage, relationshipTypes);

		return result;
	}

	/**
	 * @generated
	 */
	private ToolEntry createOnetoOne9CreationTool() {
		ImageDescriptor smallImage;
		ImageDescriptor largeImage;

		smallImage = UMLElementTypes
				.getImageDescriptor(UMLElementTypes.Association_3005);

		largeImage = smallImage;

		final List relationshipTypes = new ArrayList();
		relationshipTypes.add(UMLElementTypes.Association_3005);
		ToolEntry result = new LinkToolEntry("One to One",
				"Create a new One to One Association", smallImage, largeImage,
				relationshipTypes);

		return result;
	}

	/**
	 * @generated
	 */
	private ToolEntry createInterface1CreationTool() {
		ImageDescriptor smallImage;
		ImageDescriptor largeImage;

		smallImage = UMLElementTypes
				.getImageDescriptor(UMLElementTypes.Interface_1003);

		largeImage = smallImage;

		final List elementTypes = new ArrayList();
		elementTypes.add(UMLElementTypes.Interface_1003);
		ToolEntry result = new NodeToolEntry("Interface",
				"Create a new Session Bean", smallImage, largeImage,
				elementTypes);

		return result;
	}

	/**
	 * @generated
	 */
	private ToolEntry createOperation2CreationTool() {
		ImageDescriptor smallImage;
		ImageDescriptor largeImage;

		smallImage = UMLElementTypes
				.getImageDescriptor(UMLElementTypes.Operation_2003);

		largeImage = smallImage;

		final List elementTypes = new ArrayList();
		elementTypes.add(UMLElementTypes.Operation_2003);
		ToolEntry result = new NodeToolEntry("Operation",
				"Create a new Operation", smallImage, largeImage, elementTypes);

		return result;
	}

	/**
	 * @generated
	 */
	private ToolEntry createDependency3CreationTool() {
		ImageDescriptor smallImage;
		ImageDescriptor largeImage;

		smallImage = UMLElementTypes
				.getImageDescriptor(UMLElementTypes.Dependency_3007);

		largeImage = smallImage;

		final List relationshipTypes = new ArrayList();
		relationshipTypes.add(UMLElementTypes.Dependency_3007);
		ToolEntry result = new LinkToolEntry("Dependency",
				"Create a new Dependency", smallImage, largeImage,
				relationshipTypes);

		return result;
	}

	/**
	 * @generated
	 */
	private ToolEntry createActor1CreationTool() {
		ImageDescriptor smallImage;
		ImageDescriptor largeImage;

		smallImage = UMLElementTypes
				.getImageDescriptor(UMLElementTypes.Actor_1004);

		largeImage = smallImage;

		final List elementTypes = new ArrayList();
		elementTypes.add(UMLElementTypes.Actor_1004);
		ToolEntry result = new NodeToolEntry("Actor", "Create a new Actor",
				smallImage, largeImage, elementTypes);

		return result;
	}

	/**
	 * @generated
	 */
	private ToolEntry createUseCase2CreationTool() {
		ImageDescriptor smallImage;
		ImageDescriptor largeImage;

		smallImage = UMLElementTypes
				.getImageDescriptor(UMLElementTypes.UseCase_1005);

		largeImage = smallImage;

		final List elementTypes = new ArrayList();
		elementTypes.add(UMLElementTypes.UseCase_1005);
		ToolEntry result = new NodeToolEntry("Use Case",
				"Create a new Use Case", smallImage, largeImage, elementTypes);

		return result;
	}

	/**
	 * @generated
	 */
	private ToolEntry createAssociation3CreationTool() {
		ImageDescriptor smallImage;
		ImageDescriptor largeImage;

		smallImage = UMLElementTypes
				.getImageDescriptor(UMLElementTypes.Association_3006);

		largeImage = smallImage;

		final List relationshipTypes = new ArrayList();
		relationshipTypes.add(UMLElementTypes.Association_3006);
		ToolEntry result = new LinkToolEntry("Association",
				"Create a new Association", smallImage, largeImage,
				relationshipTypes);

		return result;
	}

	/**
	 * @generated
	 */
	private static class NodeToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List elementTypes;

		/**
		 * @generated
		 */
		private NodeToolEntry(String title, String description,
				ImageDescriptor smallIcon, ImageDescriptor largeIcon,
				List elementTypes) {
			super(title, description, smallIcon, largeIcon);
			this.elementTypes = elementTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeCreationTool(elementTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}

	/**
	 * @generated
	 */
	private static class LinkToolEntry extends ToolEntry {

		/**
		 * @generated
		 */
		private final List relationshipTypes;

		/**
		 * @generated
		 */
		private LinkToolEntry(String title, String description,
				ImageDescriptor smallIcon, ImageDescriptor largeIcon,
				List relationshipTypes) {
			super(title, description, smallIcon, largeIcon);
			this.relationshipTypes = relationshipTypes;
		}

		/**
		 * @generated
		 */
		public Tool createTool() {
			Tool tool = new UnspecifiedTypeConnectionTool(relationshipTypes);
			tool.setProperties(getToolProperties());
			return tool;
		}
	}
}
